package org.spice.servlet.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.DynamicAttributes;

public 
class LinkTag extends BaseTag implements DynamicAttributes{

	private static 
	final long serialVersionUID = 1L;
	
	private
	String url;
	
	
	public 
	String getUrl() {
		return url;
	}
	
	
	public 
	void setUrl(String url) {
		this.url = url;
	}

	@Override
	public 
	void setDynamicAttribute(String uri, String localName, Object value)
			throws JspException {
		
	}

	@Override
	public 
	int writeTag(PageContext pageContext) {
		try {
			this.pageContext.getOut().append("<a href=\""+getUrl()+"\">");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}
	
	@Override
	public int doEndTag() throws JspException {
		try {
			this.pageContext.getOut().append(" </a>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doEndTag();
	}


}
